package com.dunqi.gpm.cangxi.home.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.dunqi.gpm.cangxi.R;
import com.dunqi.gpm.cangxi.common.base.BaseAct;
import com.dunqi.gpm.cangxi.home.constance.Constance;
import com.dunqi.gpm.cangxi.home.fragment.ProjectDayReportFragment;

import butterknife.OnClick;

public class DayReportActivity extends BaseAct {

    private Long projectId;

    @Override
    protected void refreshData(Bundle savedInstanceState) {

    }

    @Override
    protected void initUiAndListener() {
        projectId = getIntent().getLongExtra(Constance.PROJECTID, 0);
        replace();
    }

    private void replace() {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, ProjectDayReportFragment.newInstance(projectId))
                .commit();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_day_report;
    }

    public static void start(Context context, Long projectId) {
        Intent intent = new Intent(context, DayReportActivity.class);
        intent.putExtra(Constance.PROJECTID, projectId);
        context.startActivity(intent);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 200) {
            //AddDayReportActivity
            replace();
        }
    }

    @OnClick(R.id.edit_tv)
    public void onViewClicked() {
        startActivity(new Intent(this, AddDayReportActivity.class));
    }
}